/*
 * vCLDART.cpp
 *
 *  Created on: May 22, 2011
 *      Author: ulas
 */

#include "vCLDART.h"

vCLDART::vCLDART() {
	this->numberOfAdos = 0;
	this->cyc = 0;
	this->cnt = 0;
	initialize_vCL();
}

STATUS vCLDART::initialize_vCL()
{
    /*Construct Allocation Data Objects*/
	//this->numberOfAdos = numberOfAdos;
	//this->cyc = totalSlots;

	ado_TYPE ado[3];
	ado[0].num = 2;
	ado[0].slots[0] = 0;
	ado[0].slots[1] = 3;
	ado[0].used.ch = 0;
	ado[0].used.nodeId = 0;
	ado[1].num = 2;
	ado[1].slots[0] = 1;
	ado[1].slots[1] = 4;
	ado[1].used.ch = 0;
	ado[1].used.nodeId = 0;
	ado[2].num = 1;
	ado[2].slots[0] = 2;
	ado[2].used.ch = 0;
	ado[2].used.nodeId = 0;
	addAdo(&ado[0]);
    addAdo(&ado[1]);
    addAdo(&ado[2]);
	this->cyc =5;

    DEVICE_CHANNEL_TYPE dc;
	dc.nodeId = 1;
	dc.ch = 2;

    setAllocUsed( 2, dc );

    return OK;
}
STATUS vCLDART::addAdo(ado_TYPE* ado)
{
	if(ado == NULL) {
		PERROR("vCLDART| Cannot Insert Specified Ado As It is Null");
		return ERROR;
	}

	this->alloc[this->numberOfAdos] = (*ado);
	this->numberOfAdos++;

	return OK;

}

STATUS vCLDART::setAllocUsed(U8 allocIndex, DEVICE_CHANNEL_TYPE Device_Channel)
{
	this->alloc[allocIndex].used = Device_Channel;
	return OK;
}

vCLDART::~vCLDART() {

}
